#coding:utf-8
from lovewith.utils.mtcache import MtCache
from lovewith.promote.models import PromoteCateTag


class CatePromoteTagApi:
    def __init__(self):
        pass

    #获取全部标签
    @staticmethod
    def get(cate_id, count=15):
        command_tag = MtCache('cate_command_tag').get(cate_id=cate_id)

        if not command_tag:
            command_tag = []
            tag_result = PromoteCateTag.objects.filter(cate_id=cate_id).order_by('-sort')[0:count]
            for tag in tag_result:
                command_tag.append({'tag': tag.tag, 'link': tag.link})

            MtCache('cate_command_tag').set(command_tag, cate_id=cate_id)
        return command_tag